package com.zjw.touchscreen.listener;

import android.annotation.SuppressLint;
import android.view.View;
import com.zjw.touchscreen.bluetooth.MouseHelper;

import java.util.concurrent.atomic.AtomicInteger;

@SuppressLint("NewApi")
public class TouchBoardLongClickListener implements View.OnLongClickListener {

    private AtomicInteger mark;

    public TouchBoardLongClickListener(AtomicInteger mark) {
        this.mark = mark;
    }

    @Override
    public boolean onLongClick(View v) {
        rightClick();
        return false;
    }

    private void rightClick() {
        if (mark.get() == 0) {
            mark.set(2);
        }
        if (mark.get() == 1) {
            return;
        }
        MouseHelper.sendData(false, true, false, 0, 0, 0);
        MouseHelper.sendKeyUp();
    }
}
